Page({
  data: {
    curUnix: wx.time.curUnix(),
    statusCode: require('../../config/statusCode').order
  },
  onLoad: function (options) {
    this.setData({
      id: options.id
    }, () => {
      // 订单详情
      wx.util.request('', {
        query: `id=${this.data.id}`
      }).then(order => {
        order.order_money = wx.util.formatAmount(order.order_money);
        order.pay_money = wx.util.formatAmount(order.pay_money);
        order.created_at = wx.time.toDate(order.created_at);
        order.pay_time = order.pay_time > 0 ? wx.time.toDate(order.pay_time) : '';
        order.consign_time = order.consign_time > 0 ? wx.time.toDate(order.consign_time) : '';
        this.setData({
          order: order
        });
      }).catch(err => {
        console.log(err);
      });
      // 快递信息
      wx.util.request('order.express', {
        query: `order_id=${this.data.id}`
      }).then(express => {
        this.setData({
          express: express
        });
      }).catch(err => {
        console.log(err);
      });
    });
  }
})